package com.hrt.manage.sms.smsRecord.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hrt.base.BaseController;
import com.hrt.bean.SmsRecord;
import com.hrt.manage.sms.smsRecord.service.SmsRecordService;
import com.hrt.util.RamUtil;

@Controller("smsRecordManageAction")
@RequestMapping("manage/smsRecord")
public class SmsRecordController extends BaseController<SmsRecord>{
	@Autowired
	@Qualifier("smsRecordManageService")
	private SmsRecordService smsRecordService;
	/**
	 * 
	 * @param orderId
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/save")
	@ResponseBody
	public String save(@RequestParam(value = "mobile", required = true) String mobile,
			@RequestParam(value = "memberId", required = true) Long memberId,
			HttpServletRequest request, HttpServletResponse response) {
		SmsRecord smsRecord = new SmsRecord();
		String code = RamUtil.getMobileVaildCode();//随机生成手机验证码
		
		String content = "恩人13694266240你好,你的手机验证码为"+code+"感谢你对何人堂创意产品网的支持,请继续关注http://www.who158.com";
		smsRecord.setVaildCode(code);//手机验证码
		smsRecord.setSendTime(smsRecordService.getDate());//发送时间
		smsRecord.setMobile(mobile);//手机号码
//		smsRecord.setBusType(newBusType);//业务类型
		smsRecord.setContent(content);//短信内容
		if(memberId!=-1){
			smsRecord.setMemberId(memberId);//用户id
			
		}
		smsRecord.setStatus(0);//验证码状态
		smsRecord.setIsdelete(0);//是否删除
	try {
		
			smsRecordService.saveSmsRecord(smsRecord);
			//SMSSender.sendSMS(content, mobile);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "success";
		
	}
}
